﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Microsoft.WindowsAzure;
using Moq;

namespace BareWeb.FluentAzureDiagnostics.Tests
{
    [TestClass]
    public class MarkerFileTests
    {
        [TestMethod]
        public void Commit_ShouldNotCommit_DoesNotInvokePutMarker()
        {
            //arrange
            var mockAzureBlob = new Mock<IAzureBlobStorage>();
            mockAzureBlob.Setup(t => t.ShouldCommit()).Returns(false);

            //act
            var target = new DiagnosticsCapture(CloudStorageAccount.DevelopmentStorageAccount, mockAzureBlob.Object);
            target.Default().WithoutLogs().Commit();


            //assert
            mockAzureBlob.Verify(t=>t.PutFluentMarker(), Times.Never());
        }

        [TestMethod]
        public void Commit_ShouldCommit_InvokesPutMarker()
        {
            //arrange
            var mockAzureBlob = new Mock<IAzureBlobStorage>();
            mockAzureBlob.Setup(t => t.ShouldCommit()).Returns(true);

            //act
            var target = new DiagnosticsCapture(CloudStorageAccount.DevelopmentStorageAccount, mockAzureBlob.Object);
            target.Default().WithoutLogs().Commit();

            //assert
            mockAzureBlob.Verify(t => t.PutFluentMarker(), Times.Once());
        }


    }
}
